# coding=utf-8
# 读取menu.js文件
import re, requests


def main(_path, _ip, _port, _sys):
    file_object = open(_path, 'r')
    all_the_text = file_object.read()
    _menu = re.sub("([\\s\\S]*)(const)(\\s*)(.menu)(\\s*)(=)(\\s*)(\\[[\\s\\S]+?\\])(;)([\\s\\S]+)", "\\8",
                   all_the_text)
    print _menu
    _url = "http://%s:%s/api/v1/menu/init?menus=%s&sys=%s" % (_ip, _port, _menu, _sys)
    requests.post(url = _url).content
    pass


if __name__ == '__main__':
    _path = '/Users/wangjian/Downloads/tom/src/config/menu.js'
    _ip = '127.0.0.1'
    _port = '8097'
    _sys = 'tom'
    main(_path, _ip, _port, _sys)
